package com.czk.netty.nio.basic;

import java.nio.ByteBuffer;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/1/11 20:57
 */
public class ByteBufferPutGet {
    public static void main(String[] args) {
        // 创建buffer
        ByteBuffer byteBuffer = ByteBuffer.allocate(64);
        // 类型化获取数据
        byteBuffer.putInt(100);
        byteBuffer.putLong(9);
        byteBuffer.putChar('陈');
        byteBuffer.putShort((short) 4);
        // 取出
        byteBuffer.flip();
        System.out.println(byteBuffer.getInt());
        System.out.println(byteBuffer.getLong());
        System.out.println(byteBuffer.getChar());
        // 顺序化读取
        System.out.println(byteBuffer.getShort());
    }

}
